/**
 * 
 */
package fhq.hcmute.modernshopping.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import fhq.hcmute.modernshopping.R;
import fhq.hcmute.modernshopping.fragment.ShoppingInfo;
import fhq.hcmute.modernshopping.fragment.ShoppingListProduct;

/**
 * @author: Hien Nguyen Le
 * @emai: hien.nguyenle.it@gmail.com
 * 
 */
public class ShoppingPagerAdapter extends FragmentPagerAdapter {
	private static final int PAGE_COUNT = 2;
	public static final int SHOPPING_INFO = 0;
	public static final int SHOPPING_LIST_PRODUCT = 1;
	private Context context;

	public ShoppingPagerAdapter(FragmentManager fm, Context context) {
		super(fm);
		this.context = context;
	}

	@Override
	public Fragment getItem(int id) {
		if (id == SHOPPING_INFO) {
			return ShoppingInfo.getInstance().setContext(context);
		}
		return ShoppingListProduct.getInstance().setContext(context);
	}

	@Override
	public CharSequence getPageTitle(int position) {
		if (position == SHOPPING_INFO) {
			return context.getString(R.string.title_activity_shopping_info);
		}
		return context.getString(R.string.title_activity_shopping_list_product);
	}

	@Override
	public int getCount() {
		return PAGE_COUNT;
	}

}
